#ifndef BASEENTITY_H
#define BASEENTITY_H
//------------------------------------------------------------------------
//
//  Name:   BaseEntity.h
//
//  Desc:   Base class for a game object
//
//  Author: Mat Buckland 2002 (fup@ai-junkie.com)
//
//------------------------------------------------------------------------

#include "LibraryFrameworkExport.h"

#include <string>
#include <iosfwd>

#include "AI/Messaging/Telegram.h"
#include "Game/GameTime.h"
#include "ComponentManager.h"

namespace CasaEngine
{
	/*
	 *	
	 */
	class LIBRARY_FRAMEWORK_EXPORT BaseEntity
	{
	private:

		//this is the next valid ID. Each time a BaseEntity is instantiated
		//this value is updated
		static int  m_iNextValidID;

	  //every entity must have a unique identifying number
	  int          m_ID;
	  // if the object depend on an other object (transform)
	  BaseEntity* m_pParent; 

	  ComponentManager* m_pComponentManager;

	  std::string m_Name;
	  
	public:

		/*
		 *	setting the ID and incrementing
		 *	the next valid ID
		 */
		BaseEntity();
		virtual ~BaseEntity();

		BaseEntity* GetParent() const;
		void SetParent(BaseEntity* val);

		ComponentManager* GetComponentMgr();

		/**
		 * 
		 */
		void  Initialize();

		//all entities must implement an update function
		void  Update(const GameTime& gameTime_);

		//all entities can communicate using messages. They are sent
		//using the MessageDispatcher singleton class
		bool  HandleMessage(const Telegram& msg);

		int ID() const; 

		std::string GetName() const;
		void SetName(std::string val);

		//entities should be able to read/write their data to a stream
		virtual void Write(std::ostream&  os)const;
		virtual void Read (std::ifstream& is);
	};

}

#endif // BASEENTITY_H
